﻿<UserControl x:Class="CBR.Views.DriveView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:Controls="clr-namespace:CBR.Components.Controls"
             xmlns:Converters="clr-namespace:CBR.Components.Converters"
             xmlns:ViewModels="clr-namespace:CBR.ViewModels"
             xmlns:Views="clr-namespace:CBR.Views"
             xmlns:Models="clr-namespace:CBR.Core.Models;assembly=CBR.Core"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">

    <UserControl.Resources>

        <!--DEVICE combo item template-->
        <DataTemplate x:Key="USBInfoTemplate" DataType="{x:Type Models:DeviceInfo}">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Manufacturer}"/>
                <TextBlock Text="{Binding Model}"/>
            </StackPanel>
        </DataTemplate>

        <!--NAME list view cell template-->
        <DataTemplate x:Key="NameCellTemplate" DataType="{x:Type ViewModels:ListSysObjectViewModel}">
            <StackPanel Orientation="Horizontal" x:Name="border">
                <Image Width="16" Height="16" Margin="3,0" 
                       Source="{Binding Path=Type, Converter={x:Static Converters:TypeToImageConverter.Instance}}" />
                <TextBlock Text="{Binding Name}"/>
            </StackPanel>
        </DataTemplate>

        <!-- Style for an individual list view item -->
        <Style x:Key="ViewItemBase" TargetType="{x:Type ListViewItem}">
            <EventSetter Event="MouseDoubleClick" Handler="Item_MouseDoubleClick" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="BorderBrush" Value="{DynamicResource CbrForegroundBrush}" />
            <Setter Property="Foreground" Value="{DynamicResource CbrForegroundBrush}" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
        </Style>

        <Style x:Key="GridViewItemStyle" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource ViewItemBase}" >
            <Setter Property="BorderBrush" Value="{DynamicResource CbrForegroundBrush}" />
            <Setter Property="Height" Value="32" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListViewItem}" >
                        <Border SnapsToDevicePixels="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
								Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
								BorderThickness="0,0,0,1"
								ToolTipService.IsEnabled="{Binding DataContext.ShowTooltipExplorer,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}}">

                            <GridViewRowPresenter />
                        </Border>

                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="Background" Value="{DynamicResource CbrBackgroundSelected}"/>
                            </Trigger>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter Property="Background" Value="{DynamicResource CbrBackgroundSelected}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>


    </UserControl.Resources>
    
    <Grid>
        <Controls:ExtendedListView x:Name="listViewContent" AllowDrop="True"
                    ItemsSource="{Binding CurrentListContent}"
                    ItemContainerStyle="{StaticResource GridViewItemStyle}"
                    Drop="listViewContent_Drop" DragOver="listViewContent_DragOver"
				    DragEnter="listViewContent_DragEnter" DragLeave="listViewContent_DragLeave">
            <Controls:ExtendedListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header="Name" Width="Auto" CellTemplate="{StaticResource NameCellTemplate}" />
                        <GridViewColumn Header="Last modification" DisplayMemberBinding="{Binding Path=LastModified}" />
                        <GridViewColumn Header="Size" DisplayMemberBinding="{Binding Path=Size, Converter={x:Static Converters:LongToFileSizeConverter.Instance}}" />
                    </GridView.Columns>
                </GridView>
            </Controls:ExtendedListView.View>
        </Controls:ExtendedListView>
    </Grid>
</UserControl>
